package com.example.administrator.easy.view;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.easy.R;
import com.example.administrator.easy.adapter.GuangRqVpAdapter;

import java.util.ArrayList;



/**
 * Created by Administrator on 2016/11/14.
 */

//广场----人气
public class GuangRqFragment extends Fragment {//
    private TabLayout tab;
    private ViewPager vp;
    private ArrayList<String> titleList;
    private ArrayList<Fragment> fmList;

    private GuangRqVpAdapter adapter;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_guang_rq,null);
        initView(view);
        initData();
        return  view;
    }

    private void initData() {
        titleList = new ArrayList<>();
        titleList.add("明星排行榜");
        titleList.add("粉丝活跃榜");
        fmList = new ArrayList<>();
        fmList.add(new GuangRqStarFragment());
        fmList.add(new GuangRqFenFragment());

        adapter = new GuangRqVpAdapter(getChildFragmentManager(),titleList,fmList);
        vp.setAdapter(adapter);
        tab.setupWithViewPager(vp);
        tab.setTabTextColors(Color.rgb(159,160,160),Color.rgb(230,57,118));
        tab.setSelectedTabIndicatorHeight(2);
    }

    private void initView(View view) {
        tab = (TabLayout) view.findViewById(R.id.guang_rq_tab);
        vp = (ViewPager) view.findViewById(R.id.guang_rq_vp);
    }
}
